﻿using Xenta.Operations;

namespace Xenta.Events
{
    /// <summary>
    /// Represents an event, which occurs, after the operation has been executed.
    /// </summary>
    public class OperationEvent : Event<IUnitOfWork, IOperation>
    {
        #region Ctors

        /// <summary>
        /// Initializes a new class instance.
        /// </summary>
        /// <param name="uow">The unit of work.</param>
        /// <param name="operation">The operation.</param>
        public OperationEvent(IUnitOfWork uow, IOperation operation)
            : base(uow, operation)
        {
            Marker = operation.GetType();
        }

        #endregion
    }

    /// <summary>
    /// Represents an event, which occurs, after the operation has been executed.
    /// </summary>
    public class PostExecuteOperation : OperationEvent
    {
        #region Ctors

        /// <summary>
        /// Initializes a new class instance.
        /// </summary>
        /// <param name="uow">The unit of work.</param>
        /// <param name="operation">The operation.</param>
        public PostExecuteOperation(IUnitOfWork uow, IOperation operation)
            : base(uow, operation)
        {
        }

        #endregion
    }

    /// <summary>
    /// Represents an event, which occurs, before the operation will be executed.
    /// </summary>
    public class PreExecuteOperation : OperationEvent
    {
        #region Ctors

        /// <summary>
        /// Initializes a new class instance.
        /// </summary>
        /// <param name="uow">The unit of work.</param>
        /// <param name="operation">The operation.</param>
        public PreExecuteOperation(IUnitOfWork uow, IOperation operation)
            : base(uow, operation)
        {
        }

        #endregion
    }
}